
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "pm", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pm.findAll", query = "SELECT p FROM Pm p"),
    @NamedQuery(name = "Pm.findByNif", query = "SELECT p FROM Pm p WHERE p.nif = :nif"),
    @NamedQuery(name = "Pm.findByRaisonSociale", query = "SELECT p FROM Pm p WHERE p.raisonSociale = :raisonSociale"),
    @NamedQuery(name = "Pm.findBySigle", query = "SELECT p FROM Pm p WHERE p.sigle = :sigle"),
    @NamedQuery(name = "Pm.findByNrc", query = "SELECT p FROM Pm p WHERE p.nrc = :nrc"),
    @NamedQuery(name = "Pm.findByDateNrc", query = "SELECT p FROM Pm p WHERE p.dateNrc = :dateNrc")})
public class Pm implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 9)
    @Column(name = "NIF", nullable = false, length = 9)
    private String nif;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "raisonSociale", nullable = false, length = 50)
    private String raisonSociale;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "sigle", nullable = false, length = 15)
    private String sigle;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "NRC", nullable = false, length = 15)
    private String nrc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date_nrc", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateNrc;
    @JoinColumn(name = "NIF", referencedColumnName = "NIF", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Personne personne;
    @JoinColumn(name = "idcategoriePM", referencedColumnName = "idCategoriePM", nullable = false)
    @ManyToOne(optional = false)
    private Categoriepm idcategoriePM;

    public Pm() {
    }

    public Pm(String nif) {
        this.nif = nif;
    }

    public Pm(String nif, String raisonSociale, String sigle, String nrc, Date dateNrc) {
        this.nif = nif;
        this.raisonSociale = raisonSociale;
        this.sigle = sigle;
        this.nrc = nrc;
        this.dateNrc = dateNrc;
    }

    public String getNif() {
        return nif;
    }

    public void setNif(String nif) {
        this.nif = nif;
    }

    public String getRaisonSociale() {
        return raisonSociale;
    }

    public void setRaisonSociale(String raisonSociale) {
        this.raisonSociale = raisonSociale;
    }

    public String getSigle() {
        return sigle;
    }

    public void setSigle(String sigle) {
        this.sigle = sigle;
    }

    public String getNrc() {
        return nrc;
    }

    public void setNrc(String nrc) {
        this.nrc = nrc;
    }

    public Date getDateNrc() {
        return dateNrc;
    }

    public void setDateNrc(Date dateNrc) {
        this.dateNrc = dateNrc;
    }

    public Personne getPersonne() {
        return personne;
    }

    public void setPersonne(Personne personne) {
        this.personne = personne;
    }

    public Categoriepm getIdcategoriePM() {
        return idcategoriePM;
    }

    public void setIdcategoriePM(Categoriepm idcategoriePM) {
        this.idcategoriePM = idcategoriePM;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nif != null ? nif.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pm)) {
            return false;
        }
        Pm other = (Pm) object;
        if ((this.nif == null && other.nif != null) || (this.nif != null && !this.nif.equals(other.nif))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.Pm[ nif=" + nif + " ]";
    }
    
}
